package backend

import (
	"github.com/gogf/gf/v2/frame/g"
)

type PositionReq struct {
	g.Meta    `path:"/backend/position/add" tags:"Position" method:"post" summary:"You first Position api"`
	GoodsName string `json:"goods_name" v:"required#商品名称不能为空" dc:"商品名称"` // 冗余设计，提升查询效率（因为一般可通过goods_id从goods_info表中查到）
	GoodsId   uint   `json:"goods_id" v:"required#商品id不能为空" dc:"商品id"`
	PicUrl    string `json:"pic_url" v:"required#图片链接不能为空" dc:"图片链接"`
	Link      string `json:"link" v:"required#跳转链接不能为空" dc:"跳转链接"`
	Sort      int    `json:"sort" dc:"排序"`
}
type PositionRes struct {
	Id uint `json:"id"`
}

type PositionDeleteReq struct {
	g.Meta `path:"/backend/position/delete" method:"delete" tags:"手工位图" summary:"删除手工位图接口"`
	Id     uint `v:"min:1#请选择需要删除的手工位图" dc:"手工位图id"`
}
type PositionDeleteRes struct{}

type PositionUpdateReq struct {
	g.Meta    `path:"/backend/position/update/{id}" method:"post" tags:"手工位图" summary:"修改手工位图接口"`
	Id        uint   `json:"id" p:"id"      v:"min:1#请选择需要修改的手工位图" dc:"手工位图Id"`
	GoodsName string `json:"goods_name" dc:"修改后商品名称"`
	GoodsId   uint   `json:"goods_id" dc:"修改后商品id"`
	PicUrl    string `json:"pic_url" dc:"修改后图片链接"`
	Link      string `json:"position" v:"required-without-all:GoodsName,GoodsId,PicUrl#修改内容不能为空"      dc:"修改后跳转链接"`
	Sort      int    `json:"sort"    dc:"排序"`
}
type PositionUpdateRes struct {
	Id uint `json:"id"`
}

type PositionGetListCommonReq struct {
	g.Meta              `path:"/backend/position/getList" method:"get" tags:"手工位图" summary:"获取手工位图列表接口"`
	GoodsName           string `json:"goods_name"   in:"query" dc:"商品名称"`
	GoodsId             uint   `json:"goods_id"   in:"query" dc:"商品id"`
	PicUrl              string `json:"pic_url"   in:"query" dc:"图片链接"`
	Link                uint   `json:"link"   in:"query" dc:"跳转链接"`
	Sort                int    `json:"sort"   in:"query" dc:"排序(根据sort字段倒序)"`
	CommonPaginationReq        // 引用通用分页请求参数
}
type PositionGetListCommonRes struct {
	// TODO：前后端分离，不返回html，而是返回json
	// g.Meta `mime:"text/html" type:"string" example:"<html/>"`
	List  interface{} `json:"position_list" description:"手工位图列表"`
	Page  int         `json:"page" description:"分页码"`
	Size  int         `json:"size" description:"分页数量"`
	Total int         `json:"total" description:"数据总数"`
}
